home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Utilities / Text / MacGREP / README < prev   
Text File  |  1991-04-21  |  4KB  |  78 lines

  1. util/macgrep-02.hqx
  2.  
  3. MacGREP 0.2
  4.  
  5.      I spent quite a while trying to locate a program on the Macintosh which
  6. performs the same function as "grep" on UNIX systems, namely that one can
  7. output from one file specific lines, which match a specified pattern, to
  8. another file -- a sort of extracting of lines. I finally found a program which
  9. does this on page 117 and 165 of "The C Programming Language" (second edition)
  10. by Kernighan and Ritchie, 1988, Prentice Hall. What I simply did was to port
  11. this small program to the Macintosh while still retaining the UNIX-style
  12. command-line argument function. I also used a modified version of the function
  13. found on page 279 of "Algorithms in C" by Sedgewick, 1990, Addison-Wesley. The
  14. major modifications were to make the program work with 2-byte encoded Japanese
  15. text in SHIFT-JIS code.
  16.      As many may know, "grep" is a UNIX function which stands for "global
  17. regular expression print," and is used to print lines from files based on
  18. pattern matching. This particular version of grep only has a few features, and
  19. I plan to add more in the near future.
  20.      Now for the instructions. This program, once launched, displays a window
  21. called "console," and a dialog with 3 basic parts:
  22.  
  23. 1) Standard Input
  24. 2) Standard Output
  25. 3) Command Line
  26.  
  27. 1) Standard Input: 2 choices are given, namely console and file. I wrote the
  28. program so that it takes its input from a file, so be sure to check the file
  29. radio button. At that point you will be prompted to locate the file you wish
  30. to use as input (using the standard Macintosh file system).
  31.  
  32. 2) Standard Output: 4 choices are given, namely console, file, console+file,
  33. and console+printer. Console means that the output of the program will be
  34. displayed in the window called "console." If you choose the output to be placed
  35. in a file, you will be prompted for the file name (using the standard Macintosh
  36. file system). Perhaps the most useful radio button is console+file since it
  37. outputs to both the window and to a file. Note that the number of lines matching
  38. the pattern is also output. This information is appended at the end.
  39.  
  40. 3) Command Line: The first item in the text window is the name of the program
  41. (I call it MacGREP). There are two optional flags you can use:
  42.  
  43. -n   This flag will also print the line number of the input file from which the
  44.      line was taken.
  45.  
  46. -x   This flag does an inverse pattern match, namely that all lines which do not
  47.      match the pattern will be output.
  48.  
  49. The only required item (besides the program name which is placed in the text
  50. window by default) is the pattern. This program accepts a single string as a
  51. search pattern. This means you can search for individual letters, parts of a
  52. word, or whole words. It has been written so that it accepts Japanese, and
  53. handles it correctly (the normal algorithms for grep won't).
  54.      I would like to mention that the TYPE of the output file (if so chosen)
  55. will be TEXT, but the CREATOR will be ????. This means that in order to view
  56. the ouput of the program you must first launch your favorite text editor or
  57. word processor, then choose OPEN. Double-clicking the file won't open it
  58. (unless you are running an application substitution program like HandOffII).
  59.      Programmer's note: I used the ccommand function described on page 171 of
  60. the Think C Standard Libraries Reference. This function handles the command-line
  61. argument handling, and displays the window and dialog. It is quite useful for
  62. running UNIX-based programs on the Macintosh. The source for MacGREP is
  63. included with this bundle.
  64.      Please send your comments and suggestions to me at klunde@macc.wisc.edu.
  65. I just ported this program yesterday (4/18/91), and I realize that it needs
  66. more features. I wrote it as a tool for extracting lines from lists of Japanese
  67. words which contain a specific Chinese character (or characters). I will supply
  68. source code upon request. You may distribute the program and its source code
  69. freely as long as ALL of the documentation is included (application, README,
  70. and source code). Parts of this program are copyright Symantec Corporation as
  71. I used Think C 4.0.2 as the development platform.
  72.      This program has been stuffed and binhexed. Enjoy!
  73.  
  74. Ken R. Lunde
  75. klunde@macc.wisc.edu
  76.  
  77. P.S. A copy of this file will be placed as a README file along with the program
  78. so that one will always have the instructions handy.